<?php
$install = true;
require_once '../common.php';
@header('Content-Type: text/html; charset=UTF-8');
if ($conf['version'] < 1039) {
	exit('网站程序版本太旧，不支持直接升级');
} elseif ($conf['version'] < 2057) {
	$sqls = file_get_contents('update2.sql');
	$version = 2057;
} elseif ($conf['version'] < 2058) {
	$sqls = file_get_contents('update3.sql');
	$version = 2058;
} elseif ($conf['version'] < 2059) {
	$sqls = file_get_contents('update4.sql');
	$version = 2059;
} else {
	exit("<script language='javascript'>alert('你的网站已经升级到最新版本了');window.location.href='/';</script>");
}
$explode = explode(';', $sqls);
$num = count($explode);
foreach ($explode as $sql) {
	if ($sql = trim($sql)) {
		$DB->query($sql);
	}
}
saveSetting('version', $version);
$CACHE->clear();
exit("<script language='javascript'>alert('恭喜您！网站数据库升级完毕！');window.location.href='/';</script>");
